#include <iostream>
#include <vector>
using std::cin;
using std::cout;
using std::vector;
using std::swap;
using std::distance;

void Input(vector <int> *list) {
    int count;
    cin >> count;
    list->reserve(count);
    int element;
    for (int i(0); i < count; ++i) {
        cin >> element;
        list->push_back(element);
    }
}

template <typename iterator = vector <int>::iterator>
void Merge(iterator first_begin, iterator first_end,
    iterator second_begin, iterator second_end,
    iterator result_begin) {
    iterator result_current = result_begin;
    while (first_begin != first_end ||
        second_begin != second_end) {
        if (second_begin == second_end ||
            (first_begin != first_end &&
            *first_begin <= *second_begin)) {
            *result_current = *first_begin;
            ++result_current;
            ++first_begin;
        }
        else
            if (first_begin == first_end ||
                (second_begin != second_end &&
                *first_begin > *second_begin)) {
                *result_current = *second_begin;
                ++result_current;
                ++second_begin;
            }
    }
}

void Output(vector <int> *list) {
    for (auto i = list->begin(); i != list->end(); ++i) {
        cout << *i << " ";
    }
}

int main() {
    vector <int> list1, list2, answer;
    Input(&list1);
    Input(&list2);
    answer.resize(list1.size() + list2.size());
    Merge(list1.begin(), list1.end(),
        list2.begin(), list2.end(), answer.begin());
    Output(&answer);
}